package example_10.setdemo;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class SetDemo_01 {
    public static void main(String[] args) {
        Set set = new HashSet();
        set.add(123);
        set.add("sdf");
        set.add("sdfffd");
        set.add(456);
        System.out.println(set);
        Object[] objs = set.toArray();
        for (int i =0;i<objs.length;i++){
            System.out.println(objs[i]);
        }
        System.out.println("---------------");
        Set<String> names = new HashSet<>();
        names.add("张三");
        names.add("lsi");
        names.add("wangdkkjskf");
        Iterator names1 = set.iterator();
        while (names1.hasNext()){
            System.out.println(names1.next());
        }
        System.out.println("============");
        for (String str:names) {
            System.out.println(str);

        }
    }
}
